package com.example.web;


import com.example.daoman.Assess;
import com.example.daoman.Cost;
import com.example.daoman.Trade;
import com.example.daoman.User;
import com.example.service.impl.*;
import com.example.utils.GetSession;
import com.example.utils.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//用户接口
@RestController
@RequestMapping("/user")
public class UserInterFace {

    @Autowired
    private UserServiceImpl userService;

    @Autowired
    private RepairServiceImpl repairService;

    @Autowired
    private CostServiceImpl costService;

    @Autowired
    private NoticeServiceImpl noticeService;

    @Autowired
    private AssessServiceImpl assessService;

    @Autowired
    private TradeServiceImpl tradeService;

//    学员查看自己的换寝室申请
    @RequestMapping("/changeRoom")
    public Message getMyChangeRoom(){
        return tradeService.getMyChangeTrade();
    }

    //    添加学员换晴是申请
    @RequestMapping("/addTrade")
    public Message addTrade(@RequestBody User user) {
        return tradeService.addTrade(user);
    }

    //    搜索功能
    @RequestMapping("/input")
    public Message inputTrade(@RequestBody User user) {
        return tradeService.inputTrade(user);
    }

    //    学员换寝室申请 查询你自己楼层中的所有的学员信息，分页查询
    @RequestMapping("/tradeAll/{page}/{pageSize}/{fid}")
    public Message getMyUserAll(@PathVariable int page, @PathVariable int pageSize, @PathVariable int fid) {
        return tradeService.getMyUserAll(page, pageSize, fid);
    }

    //    学员查询自己的考核记录
    @RequestMapping("/selectAssess")
    public Message selectUserAssess() {
        return assessService.getUserAssess();
    }

    //    用户查询所有已发布的公告
    @RequestMapping("/notice")
    public Message getNotice() {
        return noticeService.getMyNotice();
    }

    //    查询个人信息
    @RequestMapping("/one")
    public Message getOne() {
        return userService.getOne();
    }

    //    用户查询自己的申请记录信息
    @RequestMapping("/apply")
    public Message getMyApply() {
        return repairService.getUserApply();
    }

    //  根据自己所在的楼层和房间查询自己寝室的缴费记录
    @RequestMapping("/cost/{rid}/{fid}")
    public Message getMyCost(@PathVariable int rid, @PathVariable int fid) {
        return costService.getMyCost(rid, fid);
    }

    //    学员缴费
    @RequestMapping("/pay")
    public Message apply(@RequestBody List<Cost> costList) {
        return costService.postCost(costList);
    }

    //    查询自己的缴费记录
    @RequestMapping("/record")
    public Message getMy() {
        return costService.getMyCostTitle();
    }

}
